const egg = require('egg');
const Service = egg.Service;
class ymqmenuService extends Service{

 //根据用户查询其角色，并查出其权限
 async queryuserrole(roleid){
    let queryString = 'SELECT tm.menu_name,tm.id,tm.parent_id FROM t_role tr inner JOIN t_role_menu trm on tr.id=trm.role_id inner JOIN t_menu tm  on trm.menu_id=tm.id WHERE tr.id=?'
    let params = [roleid.id];
    let result = await this.app.mysql.query(queryString,params);
    return  result
  }

  async queryroleidbyurl(roleid){
    let queryString = 'SELECT tr.id, tm.menu_name,tm.id,tm.parent_id pid,tm.url ,tm.perms FROM t_role tr inner JOIN t_role_menu trm on tr.id=trm.role_id inner JOIN t_menu tm  on trm.menu_id=tm.id WHERE tr.id=?'
    let params = [roleid.id];
    let result = await this.app.mysql.query(queryString,params);
    return  result
    
  }
}
module.exports=ymqmenuService
  